﻿namespace OboutInc.EasyMenu_Pro
{
    using OboutInc.EasyMenu_Pro.Designer;
    using System;
    using System.Collections;
    using System.ComponentModel;
    using System.ComponentModel.Design;
    using System.Drawing;
    using System.Drawing.Design;
    using System.IO;
    using System.Runtime.Serialization;
    using System.Text;
    using System.Text.RegularExpressions;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.Design;
    using System.Web.UI.WebControls;
    using System.Xml;

    [Serializable, ToolboxBitmap(typeof(EasyMenu), "EasyMenu.png"), Designer(typeof(EasyMenuDesigner), typeof(IDesigner)), Themeable(true), PersistChildren(false), ParseChildren(true)]
    public class EasyMenu : CompositeDataBoundControl, INamingContainer, ISerializable
    {
        private OboutInc.EasyMenu_Pro.CSSClassesCollection _classes;
        private MenuDataItemProperties _commonSubMenuProperties;
        private MenuItemBaseCollection _items;
        private MenuItemCollectionData _itemsCollectionData;
        private string _jscriptLib;
        private string _UniqueRenderdMenuID;
        protected int collectionIndex;
        private bool DesignMode;
        private string script_version;

        public EasyMenu()
        {
            this._jscriptLib = string.Empty;
            this.DesignMode = LicenseManager.UsageMode == LicenseUsageMode.Designtime;
            this.script_version = Constants.version_year.ToString() + Constants.version_month.ToString().PadLeft(2, '0');
        }

        protected EasyMenu(SerializationInfo info, StreamingContext context)
        {
            this._jscriptLib = string.Empty;
        }

        public int AddItem(ItemBase item)
        {
            return this.Components.Add(item);
        }

        public int AddItemAt(int index, ItemBase item)
        {
            return this.Components.AddAt(item, index);
        }

        public int AddMenuItem(string id, string innerHtml, string icon, string url, string urlTarget, string onClientClick)
        {
            if ((id == null) || (id == string.Empty))
            {
                throw new Exception("obout EasyMenu AddParent: ID is not set.");
            }
            OboutInc.EasyMenu_Pro.MenuItem item = new OboutInc.EasyMenu_Pro.MenuItem {
                ID = id,
                InnerHtml = innerHtml,
                Url = url,
                UrlTarget = urlTarget,
                OnClientClick = (onClientClick == null) ? string.Empty : onClientClick,
                Icon = icon
            };
            return this.AddItem(item);
        }

        public int AddMenuItemAt(int index, string id, string innerHtml, string icon, string url, string urlTarget, string onClientClick)
        {
            if ((id == null) || (id == string.Empty))
            {
                throw new Exception("obout EasyMenu AddParent: ID is not set.");
            }
            OboutInc.EasyMenu_Pro.MenuItem item = new OboutInc.EasyMenu_Pro.MenuItem {
                ID = id,
                InnerHtml = innerHtml,
                Url = url,
                UrlTarget = urlTarget,
                OnClientClick = (onClientClick == null) ? string.Empty : onClientClick,
                Icon = icon
            };
            return this.AddItemAt(index, item);
        }

        public int AddSeparator(string id, string InnerHtml)
        {
            MenuSeparator item = new MenuSeparator {
                ID = id,
                InnerHtml = InnerHtml
            };
            return this.AddItem(item);
        }

        public int AddSeparatorAt(int index, string id, string InnerHtml)
        {
            MenuSeparator item = new MenuSeparator {
                ID = id,
                InnerHtml = InnerHtml
            };
            return this.AddItemAt(index, item);
        }

        private string ArrangePath(string prefix, string file)
        {
            string relativeUrl = Path.Combine(prefix, file).Replace(@"\", "/");
            return base.ResolveUrl(relativeUrl);
        }

        protected override void CreateChildControls()
        {
            foreach (ItemBase base2 in this.Components)
            {
                this.Controls.Add(base2);
            }
            base.CreateChildControls();
        }

        protected override int CreateChildControls(IEnumerable dataSource, bool dataBinding)
        {
            if ((this.Page.IsPostBack && (this.ItemsCollectionData != null)) && (this.ItemsCollectionData.Count > 0))
            {
                this.CreateDataMenus(this.ItemsCollectionData);
            }
            return 0;
        }

        private void CreateDataMenus(MenuItemCollectionData menuItems)
        {
            EasyMenusCollection menuss = new MenuItemData().CreatSubMenuFromDB(menuItems, this.CommonSubMenuProperties);
            Control master = this.Page.Master;
            if (master == null)
            {
                master = this.Page;
            }
            if (this.SubMenuPlaceHolderID == string.Empty)
            {
                throw new Exception("Please set the SubMenuPlaceHolderID property");
            }
            try
            {
                FindControlRecursive(master, this.SubMenuPlaceHolderID).Controls.Clear();
            }
            catch (Exception)
            {
                throw EasyMenuExceptions.MenuContainerNotFoundError(this.SubMenuPlaceHolderID);
            }
            foreach (EasyMenu menu in menuss)
            {
                if (menu.ID != this.ID)
                {
                    FindControlRecursive(master, this.SubMenuPlaceHolderID).Controls.Add(menu);
                }
            }
        }

        private void deserializeCollection()
        {
            if (this.ViewState["EasyMenu_MenuItems"] != null)
            {
                XmlDocument document = new XmlDocument();
                document.LoadXml((string) this.ViewState["EasyMenu_MenuItems"]);
                if (document.DocumentElement.HasChildNodes)
                {
                    XmlNodeList childNodes = document.DocumentElement.ChildNodes;
                    for (int i = 0; i < childNodes.Count; i++)
                    {
                        ItemBase menuComponent = (ItemBase) Type.GetType(childNodes[i].Attributes["class", ""].Value).GetConstructor(Type.EmptyTypes).Invoke(null);
                        menuComponent.Deserialize((XmlElement) childNodes[i]);
                        this.Components.Add(menuComponent);
                    }
                }
            }
        }

        private void deserializeComponentsCSSClassesCollection()
        {
            if (this.ViewState["MenuItemsCSSClasses"] != null)
            {
                XmlDocument document = new XmlDocument();
                document.LoadXml((string) this.ViewState["MenuItemsCSSClasses"]);
                if (document.DocumentElement.HasChildNodes)
                {
                    XmlNodeList childNodes = document.DocumentElement.ChildNodes;
                    for (int i = 0; i < childNodes.Count; i++)
                    {
                        CSSClasses menuComponentCSSClasses = new CSSClasses(typeof(ItemBase));
                        menuComponentCSSClasses.Deserialize((XmlElement) childNodes[i]);
                        this.CSSClassesCollection.Add(menuComponentCSSClasses);
                    }
                }
            }
        }

        public static Control FindControlRecursive(Control Root, string Id)
        {
            if (Root.ID == Id)
            {
                return Root;
            }
            foreach (Control control in Root.Controls)
            {
                Control control2 = FindControlRecursive(control, Id);
                if (control2 != null)
                {
                    return control2;
                }
            }
            return null;
        }

        protected override void LoadViewState(object savedState)
        {
            if (savedState != null)
            {
                Pair pair = (Pair) savedState;
                base.LoadViewState(pair.First);
                this.stateObject = pair.Second;
                if (this.stateObject != null)
                {
                    this.ItemsCollectionData.LoadViewState(pair.Second);
                }
            }
            this.deserializeCollection();
            this.deserializeComponentsCSSClassesCollection();
        }

        private void OnDataSourceViewSelectCallback(IEnumerable retrievedData)
        {
            if (base.IsBoundUsingDataSourceID)
            {
                this.OnDataBinding(EventArgs.Empty);
            }
            this.PerformDataBinding(retrievedData);
        }

        protected override void OnPreRender(EventArgs e)
        {
            base.OnPreRender(e);
            this.Page.Session["ob_em_collectionRendered"] = false;
            if (this.Page.Session["ob_em_easyMenus"] == null)
            {
                this.Page.Session["ob_em_easyMenus"] = new EasyMenusCollection();
            }
            this.collectionIndex = ((EasyMenusCollection) this.Page.Session["ob_em_easyMenus"]).Add(this);
            if (!((bool) this.Page.Session["ob_em_collectionRendered"]))
            {
                this.Page.Unload += new EventHandler(this.Page_Unload);
            }
        }

        private void Page_Unload(object sender, EventArgs e)
        {
            this.Page.Session["ob_em_easyMenus"] = null;
            this.Page.Session["ob_em_stylePairs"] = null;
            this.Page.Session["ob_em_collectionRendered"] = null;
        }

        protected override void PerformDataBinding(IEnumerable retrievedData)
        {
            base.PerformDataBinding(retrievedData);
            if (retrievedData != null)
            {
                string innerHtml = string.Empty;
                string id = string.Empty;
                string parentId = string.Empty;
                string url = string.Empty;
                string urlTarget = string.Empty;
                int num = 0;
                try
                {
                    foreach (object obj2 in retrievedData)
                    {
                        num++;
                        if (this.DataTextField.Length > 0)
                        {
                            innerHtml = DataBinder.GetPropertyValue(obj2, this.DataTextField, null);
                        }
                        if (this.DataIdField.Length > 0)
                        {
                            id = DataBinder.GetPropertyValue(obj2, this.DataIdField, null);
                        }
                        else
                        {
                            id = num.ToString();
                        }
                        if (this.DataParentIdField.Length > 0)
                        {
                            parentId = DataBinder.GetPropertyValue(obj2, this.DataParentIdField, null);
                        }
                        if (this.DataUrlField.Length > 0)
                        {
                            url = DataBinder.GetPropertyValue(obj2, this.DataUrlField, null);
                        }
                        if (this.DataUrlTargetField.Length > 0)
                        {
                            urlTarget = DataBinder.GetPropertyValue(obj2, this.DataUrlTargetField, null);
                        }
                        if (parentId == "0")
                        {
                            this.AddMenuItem("ob_emItem_" + id, innerHtml, string.Empty, url, urlTarget, string.Empty);
                        }
                        else
                        {
                            this.ItemsCollectionData.Add(new MenuItemData(id, innerHtml, url, parentId, urlTarget));
                        }
                    }
                }
                catch (Exception exception)
                {
                    throw exception;
                }
                if (this.ItemsCollectionData.Count > 0)
                {
                    this.stateObject = this.ItemsCollectionData.SaveViewState();
                    this.CreateDataMenus(this.ItemsCollectionData);
                }
            }
        }

        protected override void PerformSelect()
        {
            if (!base.IsBoundUsingDataSourceID)
            {
                this.OnDataBinding(EventArgs.Empty);
            }
            this.GetData().Select(this.CreateDataSourceSelectArguments(), new DataSourceViewSelectCallback(this.OnDataSourceViewSelectCallback));
            base.RequiresDataBinding = false;
            base.MarkAsDataBound();
            this.OnDataBound(EventArgs.Empty);
        }

        private string RandomString(int size)
        {
            StringBuilder builder = new StringBuilder();
            Random random = new Random();
            for (int i = 0; i < size; i++)
            {
                char ch = Convert.ToChar(Convert.ToInt32((double) ((26.0 * random.NextDouble()) + 65.0)));
                builder.Append(ch);
            }
            return builder.ToString().ToLower();
        }

        public void RemoveItem(ItemBase item)
        {
            this.Components.Remove(item);
        }

        public void RemoveItemAt(int index)
        {
            this.Components.RemoveAt(index);
        }

        public void RemoveItemByID(string ID)
        {
            foreach (ItemBase base2 in this.Components)
            {
                if (base2.ID == ID)
                {
                    this.Components.Remove(base2);
                    break;
                }
            }
        }

        protected override void Render(HtmlTextWriter writer)
        {
            if (this.DesignMode)
            {
                string str = string.Empty;
                EasyMenu menu = this;
                if (menu.Components.Count == 0)
                {
                    writer.Write("EasyMenu: Use <b>Components</b> property to create menu items.");
                }
                else
                {
                    StringBuilder builder = new StringBuilder();
                    builder.Append("<link rel='stylesheet' type='text/css' href='" + ((menu.StyleFolder != string.Empty) ? menu.StyleFolder : "/emstyles/styles") + "/style.css'>");
                    builder.Append("<div" + ((menu.CSSMenu != string.Empty) ? (" class='" + menu.CSSMenu + "'") : "") + " id='" + menu.ID + "' style='width:" + menu.Width + ";'>");
                    builder.Append("<table cellpadding=0 cellspacing=0 border=0 width='100%' style='background-color:transparent;'>");
                    if (menu.Position == MenuPosition.Horizontal)
                    {
                        builder.Append("<tr>");
                    }
                    for (int i = 0; i < menu.Components.Count; i++)
                    {
                        if (menu.Position == MenuPosition.Vertical)
                        {
                            builder.Append("<tr>");
                        }
                        if (menu.UseIcons && (menu.IconsPosition == MenuIconsPosition.Left))
                        {
                            builder.Append("<td style=\"" + (((menu.Position == MenuPosition.Vertical) || (i == 0)) ? "border-left:1px solid A7A6AA;" : "") + "border-bottom:1px solid A7A6AA; " + (((menu.Position == MenuPosition.Horizontal) || (i == 0)) ? "border-top: 1px solid A7A6AA; " : "") + "font-size: 1px; width: 20px;\">&nbsp;</td>");
                        }
                        builder.Append("<td style=\"" + (((((menu.Position == MenuPosition.Vertical) || (!menu.UseIcons && (i == 0))) || (((menu.Position == MenuPosition.Horizontal) && (menu.IconsPosition == MenuIconsPosition.Left)) && menu.UseIcons)) || (((i == 0) && (menu.Position == MenuPosition.Horizontal)) && ((menu.IconsPosition == MenuIconsPosition.Right) && menu.UseIcons))) ? (((menu.UseIcons && (menu.IconsPosition == MenuIconsPosition.Left)) && !menu.Components[i].AllowsIcon) ? "" : "border-left:1px solid A7A6AA;") : "") + (((menu.UseIcons && (menu.IconsPosition == MenuIconsPosition.Right)) && !menu.Components[i].AllowsIcon) ? "" : "border-right:1px solid A7A6AA;") + "border-bottom:1px solid A7A6AA; " + (((menu.Position == MenuPosition.Horizontal) || (i == 0)) ? "border-top: 1px solid A7A6AA; " : "") + "\">");
                        str = (menu.Components[i].InnerHtml == string.Empty) ? menu.Components[i].ID : menu.Components[i].InnerHtml;
                        builder.Append("<div style=\"font:11px Tahoma; background-color:" + (((menu.Components[i] is OboutInc.EasyMenu_Pro.MenuItem) && ((OboutInc.EasyMenu_Pro.MenuItem) menu.Components[i]).Disabled) ? "DEDEDE" : "white") + "; padding:5px; \">" + str + "</div>");
                        builder.Append("</td>");
                        if (menu.UseIcons && (menu.IconsPosition == MenuIconsPosition.Right))
                        {
                            builder.Append("<td style=\"font-size: 1px; width: 20px;border-right:1px solid A7A6AA; border-bottom:1px solid A7A6AA; " + (((menu.Position == MenuPosition.Horizontal) || (i == 0)) ? "border-top: 1px solid A7A6AA; " : "") + "\">&nbsp;</td>");
                        }
                        if (menu.Position == MenuPosition.Vertical)
                        {
                            builder.Append("</tr>");
                        }
                    }
                    if (menu.Position == MenuPosition.Vertical)
                    {
                        builder.Append("</tr>");
                    }
                    builder.Append("</table>");
                    builder.Append("</div>");
                    writer.Write(builder.ToString());
                }
            }
            else
            {
                ScriptManagerHelper helper = new ScriptManagerHelper(this);
                writer.WriteLine("<div>");
                if (Constants.SecondExpirationDate && Constants.isTrial)
                {
                    string str2 = this.RandomString(8);
                    StringBuilder builder2 = new StringBuilder();
                    builder2.Append("<div id='" + str2 + "' style='padding-top:5px; padding-bottom:5px; border: 2px solid #cccccc; height: 60 px; width:150px; font: 8pt verdana; background-color: #eeeeee; text-align:center;'>");
                    builder2.Append("<a href='http://www.obout.com/'>obout EasyMenu</a><br />");
                    builder2.Append("Evaluation has expired<br />");
                    builder2.Append("<a href='http://www.obout.com/inc/purchase.aspx'>License...</a>");
                    builder2.Append("</div>");
                    writer.WriteLine(builder2);
                }
                else
                {
                    bool flag6;
                    writer.WriteLine("<span style=\"display:none\">&nbsp;</span>");
                    if (!((bool) this.Page.Session["ob_em_collectionRendered"]))
                    {
                        string url = HttpUtility.HtmlEncode(this.Page.ClientScript.GetWebResourceUrl(base.GetType(), "OboutInc.EasyMenu_Pro.Resources.easy_menu_script.min.js"));
                        if (helper.IsAjax && this.Page.IsCallback)
                        {
                            helper.RegisterClientScriptInclude(this, "mainScript", url);
                        }
                        else
                        {
                            writer.WriteLine("<script type=\"text/javascript\" language=\"javascript\" src=\"" + url + "\"></script>");
                        }
                        string str4 = "";
                        string str5 = "";
                        EasyMenusCollection menuss = (EasyMenusCollection) this.Page.Session["ob_em_easyMenus"];
                        this.Page.Session["ob_em_stylePairs"] = new ArrayList(menuss.Count);
                        ArrayList list = (ArrayList) this.Page.Session["ob_em_stylePairs"];
                        int num2 = 1;
                        bool flag = false;
                        bool flag2 = false;
                        int index = 0;
                        while (index < menuss.Count)
                        {
                            if ((menuss[index].ID == null) || (menuss[index].ID.Length == 0))
                            {
                                menuss.RemoveAt(index);
                            }
                            else
                            {
                                if (menuss[index].EventList.Length > 0)
                                {
                                    flag2 = true;
                                }
                                list.Add("ob_em_style_" + num2);
                                if (index > 0)
                                {
                                    if (menuss[index - 1].StyleFolder.Trim().ToLower() != menuss[index].StyleFolder.Trim().ToLower())
                                    {
                                        if (!flag)
                                        {
                                            if (menuss[index - 1].StyleFolder != string.Empty)
                                            {
                                                writer.WriteLine(this.writeCSS(((this.ShowEvent == MenuShowEvent.Always) ? "" : "alternate ") + "stylesheet", this.ArrangePath(menuss[index - 1].StyleFolder, "style.css"), (this.ShowEvent == MenuShowEvent.Always) ? "" : ("ob_em_style_" + num2)));
                                            }
                                            else
                                            {
                                                string href = HttpUtility.HtmlEncode(this.Page.ClientScript.GetWebResourceUrl(base.GetType(), "OboutInc.EasyMenu_Pro.Resources.style.min.css"));
                                                writer.WriteLine(this.writeCSS(((this.ShowEvent == MenuShowEvent.Always) ? "" : "alternate ") + "stylesheet", href, (this.ShowEvent == MenuShowEvent.Always) ? "" : ("ob_em_style_" + num2)));
                                            }
                                        }
                                        bool flag3 = false;
                                        for (int j = 0; j < index; j++)
                                        {
                                            if (menuss[j].StyleFolder.ToLower() == menuss[index].StyleFolder.ToLower())
                                            {
                                                flag3 = true;
                                                list[index] = list[j];
                                            }
                                        }
                                        if (!flag3)
                                        {
                                            num2++;
                                            list[index] = "ob_em_style_" + num2;
                                            if (menuss[index].StyleFolder != string.Empty)
                                            {
                                                writer.WriteLine(this.writeCSS(((this.ShowEvent == MenuShowEvent.Always) ? "" : "alternate ") + "stylesheet", this.ArrangePath(menuss[index].StyleFolder, "style.css"), "ob_em_style_" + num2));
                                            }
                                            else
                                            {
                                                string str7 = HttpUtility.HtmlEncode(this.Page.ClientScript.GetWebResourceUrl(base.GetType(), "OboutInc.EasyMenu_Pro.Resources.style.min.css"));
                                                writer.WriteLine(this.writeCSS(((this.ShowEvent == MenuShowEvent.Always) ? "" : "alternate ") + "stylesheet", str7, "ob_em_style_" + num2));
                                            }
                                        }
                                        flag = true;
                                    }
                                    else
                                    {
                                        list[index] = list[index - 1];
                                    }
                                    menuss[index].collectionIndex = index;
                                }
                                string str15 = str4;
                                str4 = str15 + ((str4.Length == 0) ? "" : ",") + "'ob_em_" + menuss[index].ID + "'";
                                string str16 = str5;
                                str5 = str16 + ((str5.Length == 0) ? "" : ",") + "'ob_em_" + menuss[index].ID + "':'" + menuss[index].UniqueRenderdMenuID + "'";
                                index++;
                            }
                        }
                        bool flag4 = menuss.Count > 1;
                        if (!flag4 || (flag4 && !flag))
                        {
                            if (menuss[0].StyleFolder != string.Empty)
                            {
                                writer.WriteLine(this.writeCSS("stylesheet", this.ArrangePath(menuss[0].StyleFolder, "style.css"), ""));
                            }
                            else
                            {
                                string str8 = HttpUtility.HtmlEncode(this.Page.ClientScript.GetWebResourceUrl(base.GetType(), "OboutInc.EasyMenu_Pro.Resources.style.min.css"));
                                writer.WriteLine(this.writeCSS("stylesheet", str8, ""));
                            }
                        }
                        if (flag2)
                        {
                            string str9 = this.ArrangePath(this.EventsScriptPath, "easy_menu_events_" + this.script_version + ".js");
                            if (new ScriptManagerHelper(this).IsAjax && this.Page.IsCallback)
                            {
                                new ScriptManagerHelper(this).RegisterClientScriptInclude(this, "eventScript", str9);
                            }
                            else
                            {
                                writer.WriteLine("<script type=\"text/javascript\" language=\"javascript\" src=\"" + str9 + "\"></script>");
                            }
                        }
                        if (!new ScriptManagerHelper(this).IsAjax)
                        {
                            writer.Write("<script type=\"text/javascript\" language=\"javascript\">");
                            writer.Write("var ob_em_Menus = new Array(");
                            writer.Write(str4);
                            writer.Write(");");
                            writer.Write("var ob_em_MenusUniqueRep = {");
                            writer.Write(str5);
                            writer.Write("};");
                            writer.Write("</script>");
                        }
                        else
                        {
                            StringBuilder builder3 = new StringBuilder();
                            builder3.Append("var ob_em_Menus = new Array(");
                            builder3.Append(str4);
                            builder3.Append(");");
                            builder3.Append("var ob_em_MenusUniqueRep = {");
                            builder3.Append(str5);
                            builder3.Append("};");
                            new ScriptManagerHelper(this).RegisterStartupScript(this, "mcScript" + this.ID, builder3.ToString(), true);
                        }
                        this.Page.Session["ob_em_collectionRendered"] = true;
                    }
                    if (this.ShowEvent != MenuShowEvent.Always)
                    {
                        writer.Write("<iframe id=\"" + this.ID + "__iframe\" src=\"javascript:false;\" frameBorder=\"0\" class=\"menuContainerIframeUnderlay\" style=\"display:none;\"></iframe>");
                        writer.Write("<div id=\"" + this.ID + "__underlay\" class=\"menuContainerIframeUnderlay\" style=\"display:none;\"></div>");
                    }
                    foreach (EasyMenu menu2 in (EasyMenusCollection) this.Page.Session["ob_em_easyMenus"])
                    {
                        foreach (ItemBase base2 in menu2._items)
                        {
                            if (base2 is OboutInc.EasyMenu_Pro.MenuItem)
                            {
                                foreach (EasyMenu menu3 in (EasyMenusCollection) this.Page.Session["ob_em_easyMenus"])
                                {
                                    if (menu3.AttachTo == base2.ID)
                                    {
                                        ((OboutInc.EasyMenu_Pro.MenuItem) base2).HasSubmenu = true;
                                    }
                                }
                            }
                        }
                    }
                    writer.Write("<div title=\"oem:[{attachto:&quot;" + this.AttachTo.Replace(" ,", ",").Replace(", ", ",").Replace(",", "','") + "&quot;}]\" id=\"" + this.ID + "\"" + ((this.CSSMenu != string.Empty) ? (" class=\"" + this.CSSMenu + "\"") : "") + " style=\"width:" + this.Width + ";display:none;" + ((this.ShowEvent == MenuShowEvent.Always) ? "position:relative;top:0px;left:0px;" : "position:absolute;") + "\">");
                    writer.Write("<table class=\"" + this.CSSMenuItemContainer + "\" style=\"width:100%\">");
                    if (this.Position == MenuPosition.Horizontal)
                    {
                        writer.Write("<tr>");
                    }
                    int num5 = 0;
                    int num6 = 0;
                    int num7 = 0;
                    if ((this.Position == MenuPosition.Horizontal) && this.EqualDivision)
                    {
                        foreach (ItemBase base3 in this.Components)
                        {
                            if (base3.GetType().Name != "MenuSeparator")
                            {
                                num7++;
                            }
                        }
                    }
                    foreach (ItemBase base4 in this.Components)
                    {
                        if (base4.Visible)
                        {
                            bool flag5 = this.SelectedItemId == base4.ID;
                            if (this.Position == MenuPosition.Vertical)
                            {
                                writer.Write("<tr>");
                            }
                            StringWriter writer2 = new StringWriter();
                            HtmlTextWriter writer3 = new HtmlTextWriter(writer2);
                            base4.RenderControl(writer3);
                            writer3.Flush();
                            string str10 = writer2.ToString();
                            CSSClasses menuComponentCSSClasses = this.CSSClassesCollection[base4.GetType()];
                            if (menuComponentCSSClasses == null)
                            {
                                menuComponentCSSClasses = new CSSClasses();
                                this.CSSClassesCollection.Add(menuComponentCSSClasses);
                            }
                            string str11 = "";
                            if ((this.EqualDivision && (this.Position == MenuPosition.Horizontal)) && (num7 > 0))
                            {
                                if (base4.GetType().Name != "MenuSeparator")
                                {
                                    str11 = " style=\"width:" + Math.Round((double) (100.0 / ((double) num7)), 2).ToString() + "%\"";
                                }
                                else
                                {
                                    str11 = " style=\"width:0%\"";
                                }
                            }
                            string[] strArray = new string[8];
                            strArray[0] = "oem:[{emtype:\"";
                            strArray[1] = base4.GetType().Name;
                            strArray[2] = "\",";
                            strArray[3] = flag5 ? "selected:true," : "";
                            strArray[4] = (base4.AddonAttributes != string.Empty) ? base4.AddonAttributes : "";
                            strArray[5] = "nohide:\"";
                            flag6 = !base4.AutoHideMenu;
                            strArray[6] = flag6.ToString().ToLower();
                            strArray[7] = "\"}]";
                            string s = string.Concat(strArray);
                            writer.Write("<td" + str11 + " title=\"" + HttpUtility.HtmlEncode(s) + "\" id=\"" + base4.ID + "\" class=\"" + (!flag5 ? menuComponentCSSClasses.Component : menuComponentCSSClasses.ComponentOver) + "\">");
                            writer.Write("<table class=\"ob_em_mc_table\"><tr>");
                            StringBuilder builder4 = new StringBuilder("<td title=\"oem:[{emtype:'lrc'}]\" class=\"" + (!flag5 ? menuComponentCSSClasses.ComponentLeftRoundCornerCell : menuComponentCSSClasses.ComponentLeftRoundCornerCellOver) + "\" ></td>");
                            StringBuilder builder5 = new StringBuilder("<td title=\"oem:[{emtype:'i'}]\" class=\"" + (!flag5 ? menuComponentCSSClasses.ComponentIconCell : menuComponentCSSClasses.ComponentIconCellOver) + "\">");
                            if (base4.Icon != string.Empty)
                            {
                                builder5.Append("<img src=\"" + this.ArrangePath(this.IconsFolder, base4.Icon) + "\" border=\"0\" />");
                            }
                            else
                            {
                                builder5.Append("&nbsp;");
                            }
                            builder5.Append("</td>");
                            StringBuilder builder6 = new StringBuilder("<td title=\"oem:[{emtype:'c'}]\" " + ((this.UseIcons && !base4.AllowsIcon) ? "colspan=\"3\"" : "colspan=\"2\"") + " class=\"" + (!flag5 ? menuComponentCSSClasses.ComponentContentCell : menuComponentCSSClasses.ComponentContentCellOver) + "\" >");
                            if (((base4 is OboutInc.EasyMenu_Pro.MenuItem) && (((OboutInc.EasyMenu_Pro.MenuItem) base4).Url != string.Empty)) && !((OboutInc.EasyMenu_Pro.MenuItem) base4).Disabled)
                            {
                                builder6.Append("<a href=\"" + base.ResolveUrl(((OboutInc.EasyMenu_Pro.MenuItem) base4).Url) + "\"" + ((((OboutInc.EasyMenu_Pro.MenuItem) base4).UrlTarget != string.Empty) ? (" target=\"" + ((OboutInc.EasyMenu_Pro.MenuItem) base4).UrlTarget + "\"") : "") + ">");
                            }
                            builder6.Append(str10);
                            if (((base4 is OboutInc.EasyMenu_Pro.MenuItem) && (((OboutInc.EasyMenu_Pro.MenuItem) base4).Url != string.Empty)) && !((OboutInc.EasyMenu_Pro.MenuItem) base4).Disabled)
                            {
                                builder6.Append("</a>");
                            }
                            builder6.Append("</td>");
                            string str13 = "";
                            if (((base4 is OboutInc.EasyMenu_Pro.MenuItem) && !((OboutInc.EasyMenu_Pro.MenuItem) base4).HasSubmenu) || (base4 is MenuSeparator))
                            {
                                str13 = "style=\"display:none;\"";
                            }
                            StringBuilder builder7 = new StringBuilder("<td title=\"oem:[{emtype:'m'}]\" " + str13 + " align=\"right\" >");
                            builder7.Append("<div class=\"" + (!flag5 ? menuComponentCSSClasses.ComponentSubMenuCell : menuComponentCSSClasses.ComponentSubMenuCellOver) + "\">&nbsp;</div>");
                            builder7.Append("</td>");
                            StringBuilder builder8 = new StringBuilder("<td title=\"oem:[{emtype:'rrc'}]\" class=\"" + (!flag5 ? menuComponentCSSClasses.ComponentRightRoundCornerCell : menuComponentCSSClasses.ComponentRightRoundCornerCellOver) + "\" ></td>");
                            writer.Write(builder4);
                            if (this.IconsPosition == MenuIconsPosition.Left)
                            {
                                if (this.UseIcons)
                                {
                                    writer.Write(builder5);
                                }
                                writer.Write(builder6);
                                writer.Write(builder7);
                            }
                            else
                            {
                                writer.Write(builder7);
                                writer.Write(builder6);
                                if (this.UseIcons)
                                {
                                    writer.Write(builder5);
                                }
                            }
                            writer.Write(builder8);
                            writer.Write("</tr>");
                            writer.Write("</table>");
                            writer.Write("</td>");
                            num5++;
                            num6++;
                            if (((this.Position == MenuPosition.Horizontal) && (this.RepeatColumns > 1)) && ((num5 == this.RepeatColumns) && (num6 < this.Components.Count)))
                            {
                                num5 = 0;
                                writer.Write("</tr><tr>");
                            }
                            if (this.Position == MenuPosition.Vertical)
                            {
                                writer.Write("</tr>");
                            }
                        }
                    }
                    if (this.Position == MenuPosition.Horizontal)
                    {
                        writer.Write("</tr>");
                    }
                    writer.Write("</table>");
                    if (this.ShowItemDecription)
                    {
                        writer.Write("<div id=\"" + this.ID + "__itemDes\" style='diaplay:none; position:fixed; top:-2000px; padding:7px' class='easyMenuItemDescription' ></div>");
                    }
                    writer.Write("</div>");
                    StringBuilder builder9 = new StringBuilder();
                    if (!new ScriptManagerHelper(this).IsAjax)
                    {
                        writer.Write("<script type=\"text/javascript\" language=\"javascript\">");
                        writer.Write("var ob_em_" + this.ID + ";");
                    }
                    else
                    {
                        builder9.Append("var ob_em_" + this.ID + ";");
                    }
                    StringWriter writer4 = new StringWriter();
                    HtmlTextWriter writer5 = new HtmlTextWriter(writer4);
                    if (Constants.FirstExpirationDate && Constants.isTrial)
                    {
                        string str14 = this.RandomString(8);
                        StringBuilder builder10 = new StringBuilder();
                        builder10.Append("<div id='" + str14 + "' style='padding-top:5px; padding-bottom:5px; border: 2px solid #cccccc; height: 60 px; font: 8pt verdana; background-color: #eeeeee; text-align:center;'>");
                        builder10.Append("<a href='http://www.obout.com/'>obout EasyMenu</a><br />");
                        builder10.Append("Evaluation has expired<br />");
                        builder10.Append("<a href='http://www.obout.com/inc/purchase.aspx'>License...</a>");
                        builder10.Append("</div>");
                        writer5.Write("var tr=document.createElement('tr');var td=document.createElement('td');td.height='60px';td.align='center';td.id='" + this.ID + "_7r14l';td.name='" + this.ID + "';tr.appendChild(td);td.innerHTML=\"" + builder10.ToString() + "\";document.getElementById('" + this.ID + "').firstChild.firstChild.appendChild(tr);");
                    }
                    object[] objArray = new object[15];
                    objArray[0] = "try{ob_em_";
                    objArray[1] = this.ID;
                    objArray[2] = " = new ob_EasyMenu('";
                    objArray[3] = this.ID;
                    objArray[4] = "',new Array('";
                    objArray[5] = this.AttachTo.Replace(" ,", ",").Replace(", ", ",").Replace(",", "','");
                    objArray[6] = "'),";
                    objArray[7] = this.UseIcons.ToString().ToLower();
                    objArray[8] = ",";
                    flag6 = this.IconsPosition == MenuIconsPosition.Left;
                    objArray[9] = flag6.ToString().ToLower();
                    objArray[10] = ",";
                    objArray[11] = this.OffsetHorizontal;
                    objArray[12] = ",";
                    objArray[13] = this.OffsetVertical;
                    objArray[14] = ",";
                    writer5.Write(string.Concat(objArray));
                    if (this.CSSClassesCollection.Count == 0)
                    {
                        this.CSSClassesCollection.Add(new CSSClasses(typeof(OboutInc.EasyMenu_Pro.MenuItem)));
                    }
                    this.CSSClassesCollection.Render(writer5);
                    if (this.Align != MenuAlign.Advanced)
                    {
                        this.Align = this.Align;
                    }
                    if (this.Align != MenuAlign.Cursor)
                    {
                        writer5.Write(",'" + this.Align.ToString() + "','" + this.AlignMenuCorner.ToString() + "','" + this.AlignElementCorner.ToString() + "'");
                    }
                    else
                    {
                        writer5.Write(",'" + this.Align.ToString() + "','',''");
                    }
                    writer5.Write(",'" + this.ShowEvent.ToString() + "'");
                    writer5.Write("," + this.ZIndex.ToString());
                    writer5.Write("," + ((new ScriptManagerHelper(this).IsAjax && new ScriptManagerHelper(this).IsInAsyncCallback) ? "true" : "false"));
                    writer5.Write("," + ((new ScriptManagerHelperAJAXPage(this).IsAJAXPage && new ScriptManagerHelper(this).IsInAsyncCallback) ? "true" : "false"));
                    objArray = new object[9];
                    objArray[0] = ",'";
                    objArray[1] = ((ArrayList) this.Page.Session["ob_em_stylePairs"])[this.collectionIndex];
                    objArray[2] = "',";
                    flag6 = this.Position == MenuPosition.Vertical;
                    objArray[3] = flag6.ToString().ToLower();
                    objArray[4] = ", '";
                    objArray[5] = this.IconsFolder.Replace("'", "'");
                    objArray[6] = "', ['";
                    objArray[7] = Regex.Replace(this.EventList, "[^a-zA-Z,]*", "").Replace(",", "','");
                    objArray[8] = "']";
                    writer5.Write(string.Concat(objArray));
                    writer5.Write(",'" + this.UniqueRenderdMenuID + "'");
                    writer5.Write("," + (this.SelectTreeNode ? "true" : "false"));
                    writer5.Write("," + this.DropdownIncrement);
                    writer5.Write("," + this.DropInterval);
                    writer5.Write("," + (this.KeepOpen ? "true" : "false"));
                    writer5.Write("," + ((this.RepeatColumns > 1) ? "true" : "false"));
                    writer5.Write(",'" + this.ExpandStyle.ToString() + "'");
                    writer5.Write(")}catch(ex){}");
                    writer5.Flush();
                    if (!new ScriptManagerHelper(this).IsAjax)
                    {
                        writer.Write(writer4.GetStringBuilder().ToString());
                    }
                    else
                    {
                        builder9.Append(writer4.GetStringBuilder().ToString());
                    }
                    if (!new ScriptManagerHelper(this).IsAjax)
                    {
                        writer.Write("</script>");
                    }
                    else
                    {
                        new ScriptManagerHelper(this).RegisterStartupScript(this, "startScript" + this.ID, builder9.ToString(), true);
                    }
                    writer.WriteLine("</div>");
                }
            }
        }

        protected override object SaveViewState()
        {
            this.serializeCollection();
            this.serializeComponentsCSSClassesCollection();
            return new Pair(base.SaveViewState(), this.stateObject);
        }

        private void serializeCollection()
        {
            XmlDocument document = new XmlDocument();
            XmlElement newChild = document.CreateElement("easymenu", "");
            foreach (ItemBase base2 in this.Components)
            {
                XmlElement parentNode = document.CreateElement("item" + base2.ID, "");
                XmlAttribute node = document.CreateAttribute("class", "");
                node.Value = base2.GetType().FullName;
                parentNode.Attributes.Append(node);
                base2.Serialize(ref parentNode);
                newChild.AppendChild(parentNode);
            }
            document.AppendChild(newChild);
            this.ViewState["EasyMenu_MenuItems"] = document.OuterXml;
        }

        private void serializeComponentsCSSClassesCollection()
        {
            XmlDocument document = new XmlDocument();
            XmlNode newChild = document.CreateNode(XmlNodeType.Element, "easymenu", "");
            foreach (CSSClasses classes in this._classes)
            {
                XmlElement parentNode = document.CreateElement(classes.GetType().ToString());
                classes.Serialize(ref parentNode);
                newChild.AppendChild(parentNode);
            }
            document.AppendChild(newChild);
            this.ViewState["MenuItemsCSSClasses"] = document.OuterXml;
        }

        void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context)
        {
        }

        private string writeCSS(string rel, string href, string title)
        {
            string str = "";
            str = ((((str + "<script type=\"text/javascript\" language=\"javascript\">\n" + "(function(){\n") + "var head = document.getElementsByTagName('HEAD')[0];\n" + "if(head==null) head = document.body;\n") + "var linkElement = document.createElement('link');\n" + "linkElement.type = 'text/css';\n") + "linkElement.rel = '" + rel + "';\n") + "linkElement.href = '" + href + "';\n";
            if (title.Length > 0)
            {
                str = str + "linkElement.title = '" + title + "';\n";
            }
            return ((str + "head.appendChild(linkElement);\n") + "})();\n" + "</script>\n");
        }

        [Editor(typeof(UrlEditor), typeof(UITypeEditor)), Bindable(true), Description("EasyMenu's align position."), Category("Menu settings"), DefaultValue(0)]
        public MenuAlign Align
        {
            get
            {
                object obj2 = this.ViewState["Align"];
                if (obj2 == null)
                {
                    this.ViewState["Align"] = MenuAlign.Cursor;
                    return MenuAlign.Cursor;
                }
                return (MenuAlign) obj2;
            }
            set
            {
                this.ViewState["Align"] = value;
                switch (value)
                {
                    case MenuAlign.Above:
                        this.AlignMenuCorner = Corner.BottomLeft;
                        this.AlignElementCorner = Corner.TopLeft;
                        return;

                    case MenuAlign.Under:
                        this.AlignMenuCorner = Corner.TopLeft;
                        this.AlignElementCorner = Corner.BottomLeft;
                        return;

                    case MenuAlign.Left:
                        this.AlignMenuCorner = Corner.TopRight;
                        this.AlignElementCorner = Corner.TopLeft;
                        return;
                }
                this.AlignMenuCorner = Corner.TopLeft;
                this.AlignElementCorner = Corner.TopRight;
            }
        }

        [DefaultValue(1), Bindable(true), Editor(typeof(UrlEditor), typeof(UITypeEditor)), Description("EasyMenu's element corner to align."), Category("Menu settings")]
        public Corner AlignElementCorner
        {
            get
            {
                object obj2 = this.ViewState["AlignElementCorner"];
                if (obj2 == null)
                {
                    this.ViewState["AlignElementCorner"] = Corner.TopRight;
                    return Corner.TopRight;
                }
                return (Corner) obj2;
            }
            set
            {
                this.ViewState["AlignElementCorner"] = value;
            }
        }

        [Description("EasyMenu's menu corner to align."), DefaultValue(0), Editor(typeof(UrlEditor), typeof(UITypeEditor)), Bindable(true), Category("Menu settings")]
        public Corner AlignMenuCorner
        {
            get
            {
                object obj2 = this.ViewState["AlignMenuCorner"];
                if (obj2 == null)
                {
                    this.ViewState["AlignMenuCorner"] = Corner.TopLeft;
                    return Corner.TopLeft;
                }
                return (Corner) obj2;
            }
            set
            {
                this.ViewState["AlignMenuCorner"] = value;
            }
        }

        [Category("Menu settings"), DefaultValue("document"), Bindable(true), Description("Controls IDs to which the menu is to attach itself (separated by commas).")]
        public string AttachTo
        {
            get
            {
                object obj2 = this.ViewState["AttachTo"];
                if (obj2 != null)
                {
                    return (string) obj2;
                }
                return "document";
            }
            set
            {
                this.ViewState["AttachTo"] = value;
            }
        }

        [Editor(typeof(EasyMenuItemsEditor), typeof(UITypeEditor)), Description("EasyMenu common submenu properties."), NotifyParentProperty(true), DesignerSerializationVisibility(DesignerSerializationVisibility.Content), PersistenceMode(PersistenceMode.InnerProperty), Category("SubMenu Properties")]
        public MenuDataItemProperties CommonSubMenuProperties
        {
            get
            {
                if (this._commonSubMenuProperties == null)
                {
                    this._commonSubMenuProperties = new MenuDataItemProperties();
                }
                return this._commonSubMenuProperties;
            }
        }

        [NotifyParentProperty(true), Editor(typeof(EasyMenuItemsEditor), typeof(UITypeEditor)), Description("EasyMenu components collection."), Category("Behavior"), DesignerSerializationVisibility(DesignerSerializationVisibility.Content), PersistenceMode(PersistenceMode.InnerProperty)]
        public MenuItemBaseCollection Components
        {
            get
            {
                if (this._items == null)
                {
                    this._items = new MenuItemBaseCollection(this.CSSClassesCollection);
                }
                return this._items;
            }
        }

        [Browsable(false)]
        public string ComponentVersion
        {
            get
            {
                return ("3." + Constants.version_year.ToString() + "." + Constants.version_month.ToString() + "." + Constants.version_number.ToString());
            }
        }

        [Editor(typeof(MenuComponentsCSSClassesCollectionEditor), typeof(UITypeEditor)), NotifyParentProperty(true), DesignerSerializationVisibility(DesignerSerializationVisibility.Content), PersistenceMode(PersistenceMode.InnerProperty), Category("Behavior"), Description("A collection containing all Easy menu components' css classes.")]
        public OboutInc.EasyMenu_Pro.CSSClassesCollection CSSClassesCollection
        {
            get
            {
                if (this._classes == null)
                {
                    this._classes = new OboutInc.EasyMenu_Pro.CSSClassesCollection();
                }
                return this._classes;
            }
        }

        [Bindable(true), Description("CSS class name for Menu."), DefaultValue("easyMenu"), Category("Styles")]
        public string CSSMenu
        {
            get
            {
                object obj2 = this.ViewState["CSSMenu"];
                if (obj2 != null)
                {
                    return (string) obj2;
                }
                return "easyMenu";
            }
            set
            {
                this.ViewState["CSSMenu"] = value;
            }
        }

        [Bindable(true), Category("Styles"), DefaultValue("easyMenuItemContainer"), Description("CSS class name for MenuItem Containers.")]
        public string CSSMenuItemContainer
        {
            get
            {
                object obj2 = this.ViewState["CSSMenuItemContainer"];
                if (obj2 != null)
                {
                    return (string) obj2;
                }
                return "easyMenuItemContainer";
            }
            set
            {
                this.ViewState["CSSMenuItemContainer"] = value;
            }
        }

        [Description(""), Bindable(true), NotifyParentProperty(true), Category("Database settings"), DefaultValue(false)]
        public string DataIdField
        {
            get
            {
                object obj2 = this.ViewState["DataIdField"];
                if (obj2 == null)
                {
                    this.ViewState["DataIdField"] = string.Empty;
                    return string.Empty;
                }
                return (string) obj2;
            }
            set
            {
                string str = value;
                this.ViewState["DataIdField"] = str;
            }
        }

        [Description(""), DefaultValue(false), Bindable(true), NotifyParentProperty(true), Category("Database settings")]
        public string DataParentIdField
        {
            get
            {
                object obj2 = this.ViewState["DataParentIdField"];
                if (obj2 == null)
                {
                    this.ViewState["DataParentIdField"] = string.Empty;
                    return string.Empty;
                }
                return (string) obj2;
            }
            set
            {
                string str = value;
                this.ViewState["DataParentIdField"] = str;
            }
        }

        [Bindable(true), DefaultValue(false), Description(""), NotifyParentProperty(true), Category("Database settings")]
        public string DataTextField
        {
            get
            {
                object obj2 = this.ViewState["DataTextField"];
                if (obj2 == null)
                {
                    this.ViewState["DataTextField"] = string.Empty;
                    return string.Empty;
                }
                return (string) obj2;
            }
            set
            {
                string str = value;
                this.ViewState["DataTextField"] = str;
            }
        }

        [Bindable(true), Category("Database settings"), Description(""), NotifyParentProperty(true), DefaultValue(false)]
        public string DataUrlField
        {
            get
            {
                object obj2 = this.ViewState["DataUrlField"];
                if (obj2 == null)
                {
                    this.ViewState["DataUrlField"] = string.Empty;
                    return string.Empty;
                }
                return (string) obj2;
            }
            set
            {
                string str = value;
                this.ViewState["DataUrlField"] = str;
            }
        }

        [Category("Database settings"), DefaultValue(false), Description(""), NotifyParentProperty(true), Bindable(true)]
        public string DataUrlTargetField
        {
            get
            {
                object obj2 = this.ViewState["DataUrlTargetField"];
                if (obj2 == null)
                {
                    this.ViewState["DataUrlTargetField"] = string.Empty;
                    return string.Empty;
                }
                return (string) obj2;
            }
            set
            {
                string str = value;
                this.ViewState["DataUrlTargetField"] = str;
            }
        }

        [Description("EasyMenu is expanding on basis of this value."), NotifyParentProperty(true), Bindable(true), Category("Menu settings"), DefaultValue(5)]
        public int DropdownIncrement
        {
            get
            {
                object obj2 = this.ViewState["DropdownIncrement"];
                if (obj2 == null)
                {
                    this.ViewState["DropdownIncrement"] = 5;
                    return 5;
                }
                return (int) obj2;
            }
            set
            {
                int num = value;
                this.ViewState["DropdownIncrement"] = num;
            }
        }

        [Bindable(true), Description("EasyMenu is expantion speed."), NotifyParentProperty(true), Category("Menu settings"), DefaultValue(15)]
        public int DropInterval
        {
            get
            {
                object obj2 = this.ViewState["DropInterval"];
                if (obj2 == null)
                {
                    this.ViewState["DropInterval"] = 10;
                    return 10;
                }
                return (int) obj2;
            }
            set
            {
                int num = value;
                this.ViewState["DropInterval"] = num;
            }
        }

        [Bindable(true), Description("Whether the width of the Horizontal menu will be divided equally among the items"), Category("Menu settings"), DefaultValue(false)]
        public bool EqualDivision
        {
            get
            {
                object obj2 = this.ViewState["EqualDivision"];
                if (obj2 == null)
                {
                    this.ViewState["EqualDivision"] = false;
                    return false;
                }
                return (bool) obj2;
            }
            set
            {
                bool flag = value;
                this.ViewState["EqualDivision"] = flag;
            }
        }

        [Description("List of comma separated events to call for this EasyMenu."), DefaultValue(""), Bindable(true), Category("Menu settings"), Editor(typeof(UrlEditor), typeof(UITypeEditor))]
        public string EventList
        {
            get
            {
                object obj2 = this.ViewState["EventList"];
                if (obj2 != null)
                {
                    return (string) obj2;
                }
                return "";
            }
            set
            {
                this.ViewState["EventList"] = value;
            }
        }

        [Bindable(true), DefaultValue("~/emstyles/script"), Editor(typeof(UrlEditor), typeof(UITypeEditor)), Description("Path to EasyMenu events javascript file."), Category("Menu settings")]
        public string EventsScriptPath
        {
            get
            {
                object obj2 = this.ViewState["EventsScriptPath"];
                if (obj2 == null)
                {
                    this.ViewState["EventsScriptPath"] = "~/emstyles/script";
                    return "~/emstyles/script";
                }
                return (string) obj2;
            }
            set
            {
                this.ViewState["EventsScriptPath"] = value.Trim();
            }
        }

        [Category("Menu settings"), Editor(typeof(UrlEditor), typeof(UITypeEditor)), Description("EasyMenu Expand/Collapse Animation."), DefaultValue(1), Bindable(true)]
        public OboutInc.EasyMenu_Pro.ExpandStyle ExpandStyle
        {
            get
            {
                object obj2 = this.ViewState["ExpandStyle"];
                if (obj2 == null)
                {
                    this.ViewState["ExpandStyle"] = OboutInc.EasyMenu_Pro.ExpandStyle.Slide;
                    return OboutInc.EasyMenu_Pro.ExpandStyle.Slide;
                }
                return (OboutInc.EasyMenu_Pro.ExpandStyle) obj2;
            }
            set
            {
                this.ViewState["ExpandStyle"] = value;
            }
        }

        [DefaultValue("~/emstyles/icons"), Bindable(true), Category("Appearance"), Description("Path to the folder containing the icons for the menu classes."), Editor(typeof(UrlEditor), typeof(UITypeEditor))]
        public string IconsFolder
        {
            get
            {
                object obj2 = this.ViewState["IconsFolder"];
                if (obj2 == null)
                {
                    this.ViewState["IconsFolder"] = "~/emstyles/icons";
                    return "~/emstyles/icons";
                }
                return (string) obj2;
            }
            set
            {
                this.ViewState["IconsFolder"] = value.Trim();
            }
        }

        [DefaultValue(0), Bindable(true), Category("Menu settings"), Description("Specifies whether the icons should be displayed on the left side or right side of the menu.")]
        public MenuIconsPosition IconsPosition
        {
            get
            {
                object obj2 = this.ViewState["IconsPosition"];
                if (obj2 != null)
                {
                    return (MenuIconsPosition) obj2;
                }
                return MenuIconsPosition.Left;
            }
            set
            {
                this.ViewState["IconsPosition"] = value;
            }
        }

        private MenuItemCollectionData ItemsCollectionData
        {
            get
            {
                if (this._itemsCollectionData == null)
                {
                    this._itemsCollectionData = new MenuItemCollectionData();
                    if (base.IsTrackingViewState)
                    {
                        this._itemsCollectionData.TrackViewState();
                    }
                }
                return this._itemsCollectionData;
            }
        }

        [NotifyParentProperty(true), Description("The submenu will be opened even on lost focus."), Bindable(true), Category("Menu settings"), DefaultValue(false)]
        public bool KeepOpen
        {
            get
            {
                object obj2 = this.ViewState["KeepOpen"];
                if (obj2 == null)
                {
                    this.ViewState["KeepOpen"] = false;
                    return false;
                }
                return (bool) obj2;
            }
            set
            {
                bool flag = value;
                this.ViewState["KeepOpen"] = flag;
            }
        }

        [Category("Menu settings"), DefaultValue(0), Bindable(true), Description("Horizontal menu offset relative to the mouse pointer.")]
        public int OffsetHorizontal
        {
            get
            {
                object obj2 = this.ViewState["OffsetHorizontal"];
                if (obj2 != null)
                {
                    return (int) obj2;
                }
                return 0;
            }
            set
            {
                this.ViewState["OffsetHorizontal"] = value;
            }
        }

        [Bindable(true), DefaultValue(0), Description("Vertical menu offset relative to the mouse pointer."), Category("Menu settings")]
        public int OffsetVertical
        {
            get
            {
                object obj2 = this.ViewState["OffsetVertical"];
                if (obj2 != null)
                {
                    return (int) obj2;
                }
                return 0;
            }
            set
            {
                this.ViewState["OffsetVertical"] = value;
            }
        }

        [Editor(typeof(UrlEditor), typeof(UITypeEditor)), Description("EasyMenu's position."), Category("Menu settings"), DefaultValue(1), Bindable(true)]
        public MenuPosition Position
        {
            get
            {
                object obj2 = this.ViewState["Position"];
                if (obj2 == null)
                {
                    this.ViewState["Position"] = MenuPosition.Vertical;
                    return MenuPosition.Vertical;
                }
                return (MenuPosition) obj2;
            }
            set
            {
                this.ViewState["Position"] = value;
            }
        }

        [Category("Menu settings"), Bindable(true), DefaultValue(1), NotifyParentProperty(true), Description("The submenu will be opened even on lost focus.")]
        public int RepeatColumns
        {
            get
            {
                object obj2 = this.ViewState["RepeatColumns"];
                if (obj2 == null)
                {
                    this.ViewState["RepeatColumns"] = 1;
                    return 1;
                }
                return (int) obj2;
            }
            set
            {
                int num = value;
                this.ViewState["RepeatColumns"] = num;
            }
        }

        [Browsable(false)]
        public string securedPageUrl
        {
            get
            {
                object obj2 = this.ViewState["SecuredPageUrl"];
                if (obj2 != null)
                {
                    return (string) obj2;
                }
                return "javascript:false;";
            }
            set
            {
                this.ViewState["SecuredPageUrl"] = value;
            }
        }

        [DefaultValue(""), Category("Menu settings"), Bindable(true), Description("The id of the selected menu item.")]
        public string SelectedItemId
        {
            get
            {
                object obj2 = this.ViewState["SelectedItemId"];
                if (obj2 == null)
                {
                    this.ViewState["SelectedItemId"] = "";
                    return "";
                }
                return (string) obj2;
            }
            set
            {
                this.ViewState["SelectedItemId"] = value.Trim();
            }
        }

        [Description("If menu is attached to a treenode then select it."), Bindable(true), Category("Menu settings"), DefaultValue(false)]
        public bool SelectTreeNode
        {
            get
            {
                object obj2 = this.ViewState["SelectTreeNode"];
                if (obj2 == null)
                {
                    this.ViewState["SelectTreeNode"] = false;
                    return false;
                }
                return (bool) obj2;
            }
            set
            {
                this.ViewState["SelectTreeNode"] = value;
            }
        }

        [Description("Event on which EasyMenu is shown."), Editor(typeof(UrlEditor), typeof(UITypeEditor)), DefaultValue(2), Bindable(true), Category("Menu settings")]
        public MenuShowEvent ShowEvent
        {
            get
            {
                object obj2 = this.ViewState["ShowEvent"];
                if (obj2 == null)
                {
                    this.ViewState["ShowEvent"] = MenuShowEvent.ContextMenu;
                    return MenuShowEvent.ContextMenu;
                }
                return (MenuShowEvent) obj2;
            }
            set
            {
                this.ViewState["ShowEvent"] = value;
            }
        }

        [Bindable(true), Category("Menu settings"), DefaultValue(false), Description("Will show a field for menu iyem description")]
        public bool ShowItemDecription
        {
            get
            {
                object obj2 = this.ViewState["ShowItemDecription"];
                if (obj2 == null)
                {
                    this.ViewState["ShowItemDecription"] = false;
                    return false;
                }
                return (bool) obj2;
            }
            set
            {
                bool flag = value;
                this.ViewState["ShowItemDecription"] = flag;
            }
        }

        private object stateObject
        {
            get
            {
                return this.ViewState["state"];
            }
            set
            {
                this.ViewState["state"] = value;
            }
        }

        [Description("Path to the folder containing the style.css file with menu classes."), Bindable(true), Category("Appearance"), DefaultValue(""), Editor(typeof(UrlEditor), typeof(UITypeEditor))]
        public string StyleFolder
        {
            get
            {
                object obj2 = this.ViewState["StyleFolder"];
                if (obj2 == null)
                {
                    this.ViewState["StyleFolder"] = "";
                    return "";
                }
                return (string) obj2;
            }
            set
            {
                this.ViewState["StyleFolder"] = value.Trim();
            }
        }

        [Description(""), NotifyParentProperty(true), Category("Menu settings"), DefaultValue(false), Bindable(true)]
        public string SubMenuPlaceHolderID
        {
            get
            {
                object obj2 = this.ViewState["SubMenuPlaceHolderID"];
                if (obj2 == null)
                {
                    this.ViewState["SubMenuPlaceHolderID"] = string.Empty;
                    return string.Empty;
                }
                return (string) obj2;
            }
            set
            {
                string str = value;
                this.ViewState["SubMenuPlaceHolderID"] = str;
            }
        }

        private string UniqueRenderdMenuID
        {
            get
            {
                if (this._UniqueRenderdMenuID == null)
                {
                    this._UniqueRenderdMenuID = "UniqueRenderdMenuID_" + Guid.NewGuid().ToString();
                }
                return this._UniqueRenderdMenuID;
            }
        }

        [Description("Specifies whether the menu should use icons."), DefaultValue(false), Category("Menu settings"), NotifyParentProperty(true), Bindable(true)]
        public bool UseIcons
        {
            get
            {
                object obj2 = this.ViewState["UseIcons"];
                return ((obj2 != null) && ((bool) obj2));
            }
            set
            {
                this.ViewState["UseIcons"] = value;
            }
        }

        [NotifyParentProperty(true), Bindable(true), Category("Menu settings"), DefaultValue("100px"), Description("The width of the EasyMenu.")]
        public string Width
        {
            get
            {
                object obj2 = this.ViewState["Width"];
                if (obj2 == null)
                {
                    this.ViewState["Width"] = "100px";
                    return "100px";
                }
                return (string) obj2;
            }
            set
            {
                string str = value.Trim().ToLower();
                this.ViewState["Width"] = str + ((!str.EndsWith("px") && !str.EndsWith("%")) ? "px" : "");
            }
        }

        [Description("z-index css property for the menu."), Bindable(true), Category("Menu settings"), DefaultValue(0)]
        public int ZIndex
        {
            get
            {
                object obj2 = this.ViewState["ZIndex"];
                if (obj2 != null)
                {
                    return int.Parse(obj2.ToString());
                }
                return 0;
            }
            set
            {
                this.ViewState["ZIndex"] = value;
            }
        }
    }
}

